#!/bin/bash

# 清除数据卷（危险操作）
# Clean Volumes (Dangerous)

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_ROOT"

echo "⚠️  警告：此操作将删除所有数据库数据！"
echo "⚠️  WARNING: This will DELETE all database data!"
echo ""
read -p "确认继续？(yes/no): " confirm

if [ "$confirm" != "yes" ]; then
    echo "❌ 操作已取消"
    exit 0
fi

echo ""
echo "🛑 停止所有服务..."
./scripts/stop-all.sh

echo ""
echo "🗑️  清除数据卷..."

# 删除数据卷
docker volume rm aipaper_postgresql_data 2>/dev/null || echo "  PostgreSQL 数据卷不存在或已删除"
docker volume rm aipaper_mongodb_data 2>/dev/null || echo "  MongoDB 数据卷不存在或已删除"
docker volume rm aipaper_redis_data 2>/dev/null || echo "  Redis 数据卷不存在或已删除"
docker volume rm aipaper_web_node_modules 2>/dev/null || echo "  Web node_modules 数据卷不存在或已删除"

echo ""
echo "✅ 数据卷清除完成！"
echo ""
echo "💡 重新启动服务: ./scripts/start-databases.sh && ./scripts/start-services.sh"
